package com.heima.schedule;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableDiscoveryClient //开启Nacos服务注册发现
@MapperScan("com.heima.schedule.mapper")
@EnableScheduling  //开启定时任务
public class ScheduleApplication {
    public static void main(String[] args) {
        SpringApplication.run(ScheduleApplication.class , args);
        System.out.println("-------------ScheduleApplication started -------------");
    }

    //添加拦截器实现mybatis对于乐观锁的支持  添加乐观锁的拦截器  和分页拦截器配置类似
    @Bean
    public MybatisPlusInterceptor optimisticLockerIntecepter(){
        MybatisPlusInterceptor interceptor =  new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;
    }
}
